import axios from "axios";
import http from "@/api/http.js";
const baseUrl = "http://localhost:8091";
const shipmentRequest= {
//     分页查询
    loadShipment(shipment, page = 1, limit = 10, callBack) {
        let url = baseUrl + "/shipment/selectAll?page=" + page + "&limit=" + limit;
        if (shipment) {
            if (shipment.shipmentId) {
                url += "&shipmentId=" + shipment.shipmentId;
            }
            if (shipment.shipmentClientName) {
                url += "&shipmentClientName=" + shipment.shipmentClientName;
            }
            if (shipment.shipmentLotNumber) {
                url += "&shipmentLotNumber=" + shipment.shipmentLotNumber;
            }
            if (shipment.shipmentItemId) {
                url += "&shipmentItemId=" + shipment.shipmentItemId;
            }
            if (shipment.shipmentItemName) {
                url += "&shipmentItemName=" + shipment.shipmentItemName;
            }
            if (shipment.materialOutcome) {
                url += "&materialOutcome=" + shipment.materialOutcome;
            }
        }
        axios.get(url, {
            headers: {
                token: localStorage.getItem("token")
            }
        }).then(res => {
            callBack(res.data);
        })
    },
//     新增数据信息
    loadAddShipment(shipment, callBack) {
        let url = baseUrl + "/shipment/add";
        axios.post(url, shipment, {
            headers: {
                token: localStorage.getItem("token")
            }
        }).then(res => {
            callBack(res.data);
        })
    },
//     根据id查询数据信息
    loadSelectByIdShipment(shipmentId, callBack) {
        let url = baseUrl + "/shipment/selectById?shipmentId=" + shipmentId;
        axios.get(url, {
            headers: {
                token: localStorage.getItem("token")
            }
        }).then(res => {
            callBack(res.data);
        })
    },
//     根据id修改数据信息
    loadUpdateShipment(shipment,callBack){
        let url = baseUrl + "/shipment/update";
        axios.put(url,shipment,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
//     根据id删除数据信息
    loadDeleteShipment(shipmentId,callBack){
        let url = baseUrl + "/shipment/delete?shipmentId="+shipmentId;
        axios.delete(url,{
            headers:{
                token:localStorage.getItem("token")
            }
        }).then(res=>{
            callBack(res.data);
        })
    },
}
export default shipmentRequest